package com.demo.study.thread;

import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.Date;

/**
 * @author baymax
 * @since 2025-07-04
 */
public class T07_DateFormat {
    public static void main(String[] args) {
        //test1();
        DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                TemporalAccessor accessor = sdf.parse("2025-07-04");
                System.out.println(accessor);
            }).start();
        }
    }

    private static void test1() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                try {
                    System.out.println(sdf.parse("2025-07-04"));
                } catch (Exception e) {
                    e.printStackTrace(); // 会报错
                }
            }).start();
        }
    }
}
